5231

Let's Build a DDS Function Generator for Our Electronics Laboratory.

IntroductionIf you are an electronics student, hobbyist or researcher and have your own electronics lab. Then you might have many electronic instruments like multimeter, power supply, frequency counter, soldering station, oscilloscope etc. in your laboratory. There will also be another important instrument called function generator. It is sometimes also called as 'waveform generator'. This electronic instrument is use to generate waveforms of different shapes, amplitudes and frequencies and also gives us the control over these properties. It is mainly used for testing electronic devices as well as electronic circuits so it is one of the mostly used instruments. The function generators that are available in today’s market are almost digital type. Although analog are also available but digital function generators are being preferred more by the people.  Digital function generators have more advanced features in comparison to analog so their cost is also very high. So it will be difficult for some hobbyist/student to buy such costlier digital function generator. So keeping all the above points in my mind, I decided to build a DIY digital function generator that every electronic hobbyist/student can easily build by our self. So it may be a useful project for those who can't afford such costlier digital function generators like me and want to have a digital function generator in your lab.

Need of Function Generator
As mentioned above, the function generator is the mostly used instrument in electronics laboratories'. It is used for finding the characteristics of electronics devices as well as testing the electronic circuits.

Types of Function Generators
  • Function/Waveform Generator
  • Arbitrary Function/Waveform Generator
  • Audio signal generator
  • Video signal generator
  • RF Signal generator and DF vector signal generator
  • Pulse generators.
  • Seep signal generator. There is another classification of function generators based on analog and digital technology they use.
  • Analog function generators. Function generators that uses R,L and C based oscillators for generating waveform are analog function generators.
  • Digital function generators Direct Digital Synthesis(DDS) function generator is an example of digital function generator.
Direct Digital Synthesis (DDS)
Direct digital synthesis (DDS) is a method of producing an analog waveform—usually a sine wave—by generating a time-varying signal in digital form and then performing a digital-to-analog conversion. Because operations within a DDS device are primarily digital, it can offer fast switching between output frequencies, fine frequency resolution, and operation over a broad spectrum of frequencies. With advances in design and process technology, today’s DDS devices are very compact and draw little power.

How DDS Generates a sinewave?
Here’s a breakdown of the internal circuitry of a DDS device: its main components are a phase accumulator, a means of phase-to-amplitude conversion (often a sine look-up table), and a DAC. These blocks are represented in Figure 3.
A DDS produces a sine wave at a given frequency. The frequency depends on two variables, the reference-clock frequency and the binary number programmed into the frequency register (tuning word).

The binary number in the frequency register provides the main input to the phase accumulator. If a sine look-up table is used, the phase accumulator computes a phase (angle) address for the look-up table, which outputs the digital value of amplitude—corresponding to the sine of that phase angle—to the DAC. The DAC, in turn, converts that number to a corresponding value of analog voltage or current. To generate a fixed-frequency sine wave, a constant value (the phase increment—which is determined by the binary number) is added to the phase accumulator with each clock cycle. If the phase increment is large, the phase accumulator will step quickly through the sine look-up table and thus generate a high frequency sine wave. If the phase increment is small, the phase accumulator will take many more steps, accordingly generating a slower waveform.

Advantages of DDS
  • DDS devices like the AD9833 are programmed through a high speed serial peripheral-interface (SPI), and need only an external clock to generate simple sine waves.
  •  DDS devices are now available that can generate frequencies from less than 1 Hz up to 400 MHz (based on a 1-GHz clock).
  • The frequency is tunable with sub-Hertz resolution.
  • The phase is digitally adjustable.
  • Conceptually simple design and low parts count (these help keep cost down).
  • No drift due to temperature changes or aging of components (as long as the clock is stable).
  • Addition of arbitrary waveform generation is not conceptually difficult.

Disadvantages of DDS
  • Output frequency is <= 1/2 the clock frequency.
  • Amplitude is fixed; need external circuitry to change.
  • Sine wave is sample and not spectrally pure; distortion is present.
  • With careful design, these disadvantages can be minimized.

Applications of Function Generator
Some of the applications of function generators are following.
  • Generating the message signal, carrier signal and modulation in communication engineering.
  • Testing the frequency response of amplifiers.
  • Testing filters (high pass, low pass, band pass or band stop).
  • Generating clock pulses for digital circuits.
  • Analog synthesis and processing.
  • Finding the transient characteristics of electronics devices.
  • Determining the value of inductors and capacitors.
  • Repairing electronics circuits.
  • Generating noise.

List of Electronic Components (For making DIY DDS Function Generator)

  • Resistors(1k, 10k, 2.2k, 50)
  • Capacitors(22PF, 100NF, 1000UF/25V)
  • Potentiometers(50k, 100k)
  • Voltage regulators(LM7805, LM7812, LM7912
  • Push button
  • SPDT switch
  • Bridge Rectifier
  • LED(Red, 5mm)
  • Potentiometer knobs
  • Male headers(1x20)
  • 16MHz Crystal
  • 3-Pin PCB terminal
  • PCB
  • BNC socket
  • 15-0-15/2A transformer
  • Rotary encoder
  • 16x2 LCD
  • I2C adapter
  • Microcontroller(Atmega328P, DIP-28)
  • AD9833
  • TL072(DIP-8)
List of Necessary Tools (For making DIY DDS Function Generator)
  • Screw Driver
  • Saw
  • File
  • Drill
  • Gum
  • Soldering wire
  • soldering iron
  • soldering Flux
  • M3 Nut & bolt
  • MDF sheet()
  • Copper wireFor simplicity in making I divide the whole process into following steps


 Soldering Electronic Components
After testing the circuit on a bread board now you ready to solder all the electronic components. I am using a 8cmx12cm single sided PCB for making the main board. If you have no idea about soldering then may have a look on the pictures of my PCB or you can order a ready-made PCB by uploading the Gerber file of the PCB. Here I have uploaded the Gerber file of the PCB so you can download it.
 
Making the enclosure (Case or body)
Only making the circuit doesn't mean that the function generator is now ready to use. Building a proper enclosure that holds all the electronic & electrical parts are also important too.
For making the enclosure first I created a 3D design of the enclosure in Tinkercad. Instead of using 3D printing I decided to use MDF sheets for building the case. I am using 23cmx30cm MDF sheets of thickness of 5mm.
Now cut out three different pairs of sheet from a complete MDF sheet of following sizes;
124mmx200mm
90mmx200mm
90mmx114mm
After cutting the sheets of above sizes, you need to make cut out in the front side for LCD, potentiometers, rotary encoder, BNC socket and push buttons. On the back one cutout for SPST switch and another for main lead.
Now stick all the sheets with gum except back sheet.
For making your case more attractive you can use spray paint.

Programming
For programming the Atmega328P microcontroller, I am using arduino IDE because it is easy to use and it is open source. For controlling the AD9833 chip, you need to download the following library from GitHub
https://github.com/Billwilliams1952/AD9833-Library-Arduino
After downloading the library you further need to install it. If you don't know how to do that then you can watch a video about it on you tube.
you can download the main code file from my GitHub repository. The link is following;
https://github.com/ramjipatel041/DIY-DDS-Function-Generator-For-Electronics-Lab.

Fixing Electronics Parts inside the Enclosure
You can watch the video about fixing electronic parts inside the enclosure;
https://www.youtube.com/watch?v=pQnxC_t85a4

Final Testing
Final testing video is here;
https://www.youtube.com/watch?v=prCXWfC9ewM